package org.lqk.zookeeper.curator;

import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.RetryNTimes;

public class Demo {
	private static final String ZK_ADDRESS = "192.168.3.7:2181";
	private static final String ZK_PATH = "/lqk";

	public static void main(String[] args) throws Exception {
		
		/*
		 * 创建client有两种方式
		 */
		
		CuratorFramework client = CuratorFrameworkFactory.newClient(ZK_ADDRESS, new RetryNTimes(10, 5000));
		
		/*
		 * CuratorFramework提供了命名空间的概念,避免多个应用的节点的名称冲突
		 * 使用命名空间后（假设叫abc），你创建了一个目录edf，那么实际的目录就会时/abc/edf
		 */

//		CuratorFramework    client = CuratorFrameworkFactory.builder().namespace("/lqk").build();

		client.start();

		System.out.println(new String(client.getData().forPath(ZK_PATH)));
	}
}
